// 顶栏点击事件
const a = document.querySelector(".topPreset a")
a.addEventListener("touchstart", function () {
	history.back()
})
// 提取数据
const taskInfo = JSON.parse(localStorage.getItem("deliveryInfo"))
const index = new URLSearchParams(location.search).get("id") || 0
console.log("index = " + index)
// 渲染数据
const delayTime = document.querySelector(".content .box1 .right")
delayTime.innerText = taskInfo[index].pickupTime || "2022.05.04 13:00"
// 渲染延迟时间数据
// const delayTime = document.querySelector(".content .box1 .right");
// delayTime.innerText = taskInfo[index].pickupTime || "2022.05.04 13:00";
//延迟提货的原因
const textarea = document.querySelector("textarea")
const num = document.querySelector("#num")
const btn = document.querySelector("button")
let flag = 0
btn.disabled = true
textarea.addEventListener("input", function () {
	let length = textarea.value.length
	num.innerText = length
	const active = document.querySelector("button.active")
	if (length) {
		flag = 1
		btn.disabled = false
		btn.classList.add("active")
	} else {
		btn.disabled = true
		flag = 0
		active && active.classList.remove("active")
	}
})
// 文字显示
const floatingTips = document.querySelector(".floatingTips")
btn.addEventListener("click", function () {
	taskInfo[index].isDelay = true
	floatingTips.style.opacity = "1"
	localStorage.setItem("deliveryInfo", JSON.stringify(taskInfo))
	// console.log(taskInfo)
	setTimeout(function () {
		location.href = `../../module04/mainFunctionPage.html?id=${index}`
	}, 3000)
})

const dTime = document.querySelector(".content .box2 a")
dTime.addEventListener("touchstart", function () {
	document.querySelector(".screenMask").style.opacity = 1
	document.querySelector(".screenMask").style.zIndex = 2
})
